package com.example.test;

import java.io.FileNotFoundException;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
 * @author lamtt
 * create: 07/02/2013
 * BaseDatabase class for conect database
 */
public  class SQLiteConnectionManager extends SQLiteOpenHelper{
	////////////////////////////////////////////////////////////////////////////
	// static
	////////////////////////////////////////////////////////////////////////////


	////////////////////////////////////////////////////////////////////////////
	// public method
	////////////////////////////////////////////////////////////////////////////
	/**Contructor
	 * @param context
	 */
	public SQLiteConnectionManager(Context context) {
		super(context, ConfigLib.DATABASE_NAME, null, ConfigLib.DATABASE_VERSION);
	}
	
	
	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase)
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		createTable(db);
		
		
	}
	
	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int)
	 */
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		
		
	}
	
	////////////////////////////////////////////////////////////////////////////
	// private method
	////////////////////////////////////////////////////////////////////////////
	/**create all Table
	 * @param db SQLiteDatabase
	 */
	private void createTable(SQLiteDatabase db)
	{
		createVocabularyTables(db);

	}
	
	/**create Favorite Tables
	 * @param db SQLiteDatabase
	 */
	private void createVocabularyTables(SQLiteDatabase db) {
		
		db.execSQL("CREATE TABLE " + Vocabulary.TABLE_NAME + " (" + Vocabulary._ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + Vocabulary.KANJI
				+ " TEXT, " + Vocabulary.JP_STRAN
				+ " TEXT, " + Vocabulary.VN_STRAN
				+ " TEXT, " + Vocabulary.SESSION
				+ " INTEGER);");
	}


}
